import { useStorageStore } from "src/stores/storage";
import { computed } from "vue";
import { FormatDateTime } from "src/utils/date";
import { useI18n } from "vue-i18n";
import DcDictCell from "src/components/DcDictCell/DcDictCell.vue";

export default function useCommon() {
  const { t } = useI18n;
  const storageStore = useStorageStore();
  const dcFrontend = computed(() => storageStore.GetDcFrontend());
  const dcBackend = computed(() => storageStore.GetDcBackend());
  const dcDict = computed(() => storageStore.GetDcDict());

  const openLink = (url) => {
    window.open(url);
  };
  const showDateTime = computed(() => {
    return (datetime) => {
      return FormatDateTime(datetime);
    };
  });

  //TODO: 白名单从后端获取
  const AllowList = ["/login", "/test"];
  const DcFallbackUsername = () => t("FallbackUsername");
  const DcFallbackAvatar = "images/telecom.png";
  const DcFallbackFrontend = {
    mainTitle: "蚌埠电信数据门户(Fallback MainTitle)",
    subTitle: "蚌埠电信数据门户(Fallback SubTitle)",
    webDescribe: "蚌埠电信数据门户(Fallback webDescribe)",
    showGit: "no",
  };
  const DcFallbackBackend = {};

  return {
    DcDictCell,
    showDateTime,
    dcFrontend,
    dcBackend,
    dcDict,
    openLink,
    AllowList,
    DcFallbackUsername,
    DcFallbackAvatar,
    DcFallbackFrontend,
    DcFallbackBackend,
  };
}
